package daybook.io.args;

import com.beust.jcommander.Parameter;
import com.beust.jcommander.Parameters;
import com.beust.jcommander.ParametersDelegate;
import daybook.io.formatter.Format;

import java.util.Objects;

import static daybook.Resources.RESOURCES_NAME;
import static daybook.Resources.Usages.*;

@Parameters(separators = "=", resourceBundle = RESOURCES_NAME,
        commandDescriptionKey = COMMAND_GENERATE)
public class CommandGenerate {
    @Parameter(names = {"--config"}, arity = 1,
            descriptionKey = CONFIG_FILE)
    private String config = "./config.json";

    @Parameter(names = {"--outputdir", "-d"}, arity = 1,
            descriptionKey = OUTPUT_DIRECTORY)
    private String outputDirectory = ".";

    @ParametersDelegate
    private final FormatArgs formatArgs;

    public CommandGenerate(FormatArgs formatArgs) {
        this.formatArgs = Objects.requireNonNull(formatArgs);
    }

    public String getConfig() {
        return config;
    }

    public String getOutputDirectory() {
        return outputDirectory;
    }

    public Format getFormat() {
        return formatArgs.getFormat();
    }

    @Override
    public String toString() {
        return "CommandGenerate{" +
                "config='" + config + '\'' +
                ", outputDirectory='" + outputDirectory + '\'' +
                ", formatArgs=" + formatArgs +
                '}';
    }
}
